var app = getApp();
Page({
  data: {
    userInfo: {},
    data_url: "",
    user_openid: "",
    showModal: false,
    tdIncome:'',
    twIncome:'',
    tmIncome:''
  },
  jumpToMy_circle(){
    wx.request({
      url: app.globalData.data_url + '/GPD/getMerchantAndFee.do',
      data:{
        session_id: app.globalData.sessionId
      },
      success(res){
        if(res.data.code==='0'){
          wx.navigateTo({
            url: '/pages/my_code/my_code',
          })
        } else if (res.data.code === '1'){
          wx.showToast({
            title: '对不起，您还没有商圈~',
            icon:"none",
            duration:2000
          })
        }
      }
    })
    
  },
  close:function(){
    wx.navigateBack({
      delta: 1,
    })
  },
  jumpMyInvestCode:function(){
    if(true){
      wx.navigateTo({
        url: "/pages/my_investCode/my_investCode"
      })
    }else{
      wx.showModal({
        title: '提示',
        content: '您还不是我们的会员哦',
        showCancel: false,
        confirmText: '知道了',
        confirmColor: '#ea6644',
      })
    }
  }, 
  getPhoneNumber: function (e) {
    var that = this
    wx.request({
      url: app.globalData.data_url + '/GPD/getPhoneNumber',
      data: {
        iv: e.detail.iv,
        encryptedData: e.detail.encryptedData,
        session_id: app.globalData.sessionId,
      },
      success:function(res){
        if(res.data.code == 0){
          that.setData({
            showModal: false
          })
        }
      }
    })
  },
  callNum: function (e) {
    wx.makePhoneCall({
      phoneNumber: '0871-63347768',
    })
  },
  junpToWithdraws(){
    wx.navigateTo({
      url: '/pages/withdrawals/withdrawals',
    })
  },
  junpToVipcenter(){
    wx.navigateTo({
      url: '/pages/vip_center/vip_center',
    })
  },
  onLoad: function (options) {
    var that = this;
    this.setData({
      data_url: app.globalData.data_url
    })
    wx.getUserInfo({
      success: function (res) {
        that.setData({
          userInfo: res.userInfo
        })
      },
    })
    wx.request({
      url: app.globalData.data_url + '/GPD/checkPhoneNumber',
      data:{
        session_id: app.globalData.sessionId,
      },
      success:function(res){
        if (res.data.code==="1"){
          that.setData({
            showModal:true
          })
        } else if (res.data.code === "0"){
          // 请求今日收益
          wx.request({
            url: app.globalData.data_url +'/GPD/getToDayFee.do',
            data:{
              session_id:app.globalData.sessionId
            },
            success(res){
              that.setData({
                tdIncome: res.data.tdfee
              })
            }
          })
          // 请求本周收益
          wx.request({
            url: app.globalData.data_url +'/GPD/getToWeekFee.do',
            data:{
              session_id:app.globalData.sessionId
            },
            success(res){
              that.setData({
                twIncome: res.data.twfee
              })
            }
          })
          // 请求本月收益
          wx.request({
            url: app.globalData.data_url +'/GPD/getToMonthFee.do',
            data:{
              session_id:app.globalData.sessionId
            },
            success(res){
              that.setData({
                tmIncome: res.data.tmfee
              })
            }
          })
        }
      },
    })
    // wx.login({
    //   success: function (res) {
    //     wx.request({
    //       url: "https://api.weixin.qq.com/sns/jscode2session",
    //       data: {
    //         appid: "wx528d33d8e65d7611",
    //         secret: "9f766eb2b4c2a0ace526d8456bb3d596",
    //         js_code: res.code,
    //         grant_type: "authorization_code"
    //       },
    //       success: function (res) {
    //         that.setData({
    //           user_openid: res.data.openid
    //         })
    //       }
    //     })
    //   }
    // })
  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  }
})		